package com.naiking.ui
{
	import com.naiking.interfaces.ITipBar;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	
	
	/**
	 * @author Nai.King
	 * 创建时间：2013-9-25 上午9:39:37
	 * 
	 */
	public class BaseTipBar extends Sprite implements ITipBar
	{
		private var _txt:TextField;
		private var _bg:Shape;
		public function BaseTipBar()
		{
			_bg =new Shape();
			_bg.graphics.beginFill(0xDDDDDD);
			_bg.graphics.lineStyle(1,0x999999);
			_bg.graphics.drawRect(0,0,35,32);
			_bg.graphics.endFill();
			_txt =new TextField();
			_txt.autoSize="left";
			_txt.embedFonts = false;
			_txt.multiline = true;
			_txt.x = 5;
			_txt.y = 5;
			addChild(_bg);
			addChild(_txt);
			
			mouseChildren=mouseEnabled=false;
		}
		
		public function set data(tip:String):void
		{
			_txt.htmlText = tip;
			_txt.width = Math.min(_txt.textWidth + 5, 300);
			_txt.height = _txt.textHeight + 5;
			resize();
		}
		public function resize():void
		{
			_bg.width = _txt.width + 10;
			_bg.height = _txt.height + 10;
		}
	}
}